package cn.fws.meap.weiChatWeb.tesk;

import cn.fws.meap.community.vo.AccessToken;
import cn.fws.meap.utils.WechatUtils;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;
/**
 * 获取accessToken 时间是7200秒
 * 设置定时时间刷新accessToken一个小时刷新一次
 */
@Component
@EnableScheduling
public class GetAccessToken {
        //每天的每一个小时执行一次
        @Scheduled(cron="0 0 0/1 * * ? ")
        public void executeFileDownLoadTask() {

            AccessToken accessToken =null;
            try {
                accessToken = WechatUtils.getAccessToken();
            } catch (IOException e) {
                e.printStackTrace();
            }
            System.out.println("accessToken :"+accessToken.getToken());
            System.out.println("ExpiresIn :"+accessToken.getExpiresIn());
        }
}
